<template>
  <div class="flex padding-top-bottom-20 justify-between">
    <div class="padding-left-right-40 flex justify-center flex-1">
      <div class="padding-right-50">
        <div class="padding-bottom-20">累计{{typeName}}</div>
        <div>
          <span>{{ model.currCashAmount | moneyFilterNoUnit }}</span>
          <span>万元</span>
        </div>
      </div>
      <div>
        <div class="padding-bottom-20">
          <span>全年计划{{typeName}}</span>
          <span class="font-weight-700">{{ model.planAmount | moneyFilterNoUnit }}</span>
          <span>万元</span>
        </div>
        <div>
          <span>累计计划{{typeName}}</span>
          <span class="font-weight-700">{{ model.currPlanAmount | moneyFilterNoUnit }}</span>
          <span>万元</span>
        </div>
      </div>
      <div>
        <div class="padding-bottom-20">
          <span class="padding-left-70">计划达成率</span>
          <span>{{ Math.abs(model.planCompletionRate || 0) | accMul }}%</span>
        </div>
        <div>
          <span class="padding-left-70">差异率</span>
          <span :class="model.planDifferenceRate > 0 ? 'color-green' : 'color-red'">{{ model.planDifferenceRate >= 0 ? '↑' : '↓' }}{{ Math.abs(model.planDifferenceRate || 0) | accMul }}%</span>
        </div>
      </div>
    </div>
    <div class="split-line"></div>
    <div class="padding-left-right-40 flex justify-center flex-1">
      <div class="padding-right-50">
        <div class="padding-bottom-20">预测全年{{typeName}}</div>
        <div>
          <span>{{ model.forecastYearAmount | moneyFilterNoUnit }}</span>
          <span>万元</span>
        </div>
      </div>
      <div class="padding-right-50">
        <div class="padding-bottom-20">计划全年{{typeName}}</div>
        <div>
          <span>{{ model.planAmount | moneyFilterNoUnit }}</span>
          <span>万元</span>
        </div>
      </div>
      <div>
        <div class="padding-bottom-20">
          <span>差异值</span>
          <span class="font-weight-700" :class="model.forecastDifferenceAmount <= 0 ? 'color-green' : 'color-red'">{{ model.forecastDifferenceAmount | moneyFilterNoUnit }}万元</span>
        </div>
        <div>
          <span>差异率</span>
          <span :class="model.forecastDifferenceRate <= 0 ? 'color-green' : 'color-red'">{{ model.forecastDifferenceRate <= 0 ? '↑' : '↓' }}{{ Math.abs(model.forecastDifferenceRate || 0) | accMul }}%</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    props: {
      type: {
        type: String,
        default: '',
      },
      model: {
        type: Object,
        default: () => {
          return {};
        },
      },
    },

    watch: {
      type: {
        immediate: true,
        handler(val) {
          this.typeName = val == 'income' ? '现金流入' : '支出';
        },
      },
    },

    data() {
      return {
        typeName: '',
      };
    },
  };
</script>

<style lang="scss" scoped>
  .split-line {
    width: 1px;
    height: 50px;
    background: #e5e5e5;
  }
</style>
